home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-01-01 | 1.5 KB | 39 lines | [TEXT/ttxt] |
- ____________________________________________________________________
-
- 4th Dimension Technical Notes
-
- #11 Automatic formatting of phone number fields
-
- Written by Dave Dell'Aquila July 22, 1987
-
- Published August 1, 1987
- ____________________________________________________________________
-
- Automatic formatting of phone number fields.
- ___________________________________________________________
-
- This code shows how to format a phone number field so that it always appears as XXX-XXX-XXXX.
- It can accept numbers entered as (xxx)xxx-xxxx, (xxx) xxx-xxxx, xxx-xxx-xxxx, xxxxxxxxxx, and
- xxxxxxx. This will typically appear in the During phase of an Input Layout procedure.
-
- : (Modified(Phone))
- Case of
- : (Length(Phone)=7)
- Phone:=Substring(Phone;1;3)+"-"+Substring(Phone;4;4)
- : (Length(Phone)=10)
- Phone:=Substring(Phone;1;3)+"-"+Substring(Phone;4;3)+"-"+Substring(Phone;7;4)
- : (Substring(Phone;1;1)=Char(40)) `Phone starts with a left paren
- Case of
- : ((Substring(Phone;6;1)=Char(32))|(Substring(Phone;6;1)=Char(45))
- `case of space or dash after the close paren
- Phone:=Substring(Phone;2;3)+"-"+Substring(Phone;7;Length(Phone))
- Else
- ` no space after the close paren
- Phone:=Substring(Phone;2;3)+"-"+Substring(Phone;6;Length(Phone))
- End case
- End case
-
- #11: Formatting Alpha fields Page 1 of 1
-
-
-